package com.iss.apartmentmanage.controller.room;

import com.iss.apartmentmanage.entity.HotelArea;
import com.iss.apartmentmanage.model.MyResponseData;
import com.iss.apartmentmanage.service.impl.HotelAreaServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/hotelArea")
public class HotelAreaController {
    @Autowired
    HotelAreaServiceImpl hotelAreaService;

    /*
    *查询所有的区域
     */
    @RequestMapping("/selectAllHotelArea")
    public MyResponseData selectAllHotelArea(){
        List<HotelArea> hotelAreas = hotelAreaService.selectAllHotelArea();
        MyResponseData myResponseData = new MyResponseData();
        if(hotelAreas!=null) {
            myResponseData.setObjectList(hotelAreas);
            myResponseData.setErrorCode(1);
            myResponseData.setMsg("success");
        }else{
            myResponseData.setErrorCode(0);
            myResponseData.setMsg("false");
        }
        return myResponseData;
    }

    /*
     *通过id查询所有的区域
     */
    @RequestMapping("/selectAreaById")
    public MyResponseData selectAreaById(@RequestParam Integer id){
        MyResponseData myResponseData = new MyResponseData();
        HotelArea hotelAreas=hotelAreaService.selectAreaById(id);
        if (hotelAreas!=null){
            myResponseData.setObject(hotelAreas);
            myResponseData.setErrorCode(1);
            myResponseData.setMsg("success");
        }else {
            myResponseData.setErrorCode(0);
            myResponseData.setMsg("false");
        }
        return myResponseData;
    }
}
